import echarts from 'echarts'
const pieProcess = (maxRadius,pieData) => {
  let scaleRate = maxRadius / 100;
  let pieNames=pieData.names;
  let pieValues=pieData.values;
  let compPer=0;
  let unCompPer=0;
  if (pieValues[0]){
    compPer=Math.round(pieValues[1]/pieValues[0]);
    unCompPer=100-compPer;
  }
  let mainData = [{
    name: pieNames[0],
    value: unCompPer,
    // itemStyle: {color: 'rgb(0,153,255)'},
    // hoverAnimation: false,
    label: {
      show: false,
      position: 'center',
      textStyle: {
        fontFamily: '微软雅黑',
        fontWeight: 'bolder',
        color: '#80cdff',
        fontSize: 24 * scaleRate
      }
    },
    labelLine: {
      show: false
    }
  },
    {
      name: pieNames[1],
      value: compPer,
      //itemStyle: {color: 'rgba(0,153,255,0.5)'},
      // hoverAnimation: false,
      label: {
        show: false,
        position: 'center',
        padding: 20 * scaleRate,
        textStyle: {
          fontFamily: '微软雅黑',
          fontSize: 24 * scaleRate,
          color: '#91d2ff'
        }
      },
      labelLine: {
        show: false
      }
    }];
  return {
    color:['rgba(0,153,255,0.81)','rgba(145,210,255,0.81)','#fff'],
    title: {
      text: pieNames[1],
      subtext: compPer+'%',
      x: 'center',
      y: 'center',
      itemGap: 10,
      textStyle: {
        color: '#91d2ff',
        fontWeight: 'normal',
        fontFamily: '微软雅黑',
        fontSize: 24*scaleRate
      },
      subtextStyle: {
        color: '#91d2ff',
        fontWeight: 'bolder',
        fontSize: 24*scaleRate,
        fontFamily: '微软雅黑'
      }
    },
    legend:{
			top: 'top',
			textStyle: {
				color: '#e6e6e6',
				fontSize:15*scaleRate,
				fontFamily:'微软雅黑'
			},
			data:pieNames
		},
    tooltip: {
      trigger: 'item',
      backgroundColor:'#fff',
      formatter: function (params) {
        return params.name + ' : ' + params.value*pieValues[0]/100;
      },
      textStyle: {
        color: '#050505',
        fontSize: 24*scaleRate
      }
    },
    series: [{
      type: 'pie',
      center: ['50%', '50%'],
      radius: [75*scaleRate, 90*scaleRate],
      x: '0%',
      tooltip: {show: true},
      data: mainData
    },
      {
        type: 'pie',
        center: ['50%', '50%'],
        radius: [95*scaleRate, 100*scaleRate],
        x: '0%',
        hoverAnimation: false,
        tooltip: {show: true},
        data: [{
          value: 100,
          name:pieNames[0],
          itemStyle: {color: 'rgba(0,153,255,0.3)'}, //rgba(0,153,255,0.3)
          label: {show: false},
          labelLine: {show: false}
        }]
      },
      {
        type: 'pie',
        center: ['50%', '50%'],
        radius: [69*scaleRate, 70*scaleRate],
        x: '0%',
        hoverAnimation: false,
        tooltip: {show: true},
        data: [{
          value: 100,
          name:pieNames[0],
          itemStyle: {color: 'rgba(0,153,255,0.3)'}, //rgba(0,153,255,0.3)
          label: {show: false},
          labelLine: {show: false}
        }]
      }]
  };
};

const lineBar = lbObj => {
  const {title, names, unit, xData, yData} = lbObj
  let fontsize=12;
  var color=['rgba(255,153,0,0.81)','rgba(0,224,218,0.81)','rgba(61,240,152,0.8)','rgba(51,183,52,0.81)'];
  let seriesArr=[]
  for (let idx in names){
    const name = names[idx]
    const ydata= yData[idx]
    seriesArr.push({
				name:name,
				type:'line',
				smooth :false,
        label: {
           show: true,
           position: 'top',
           textStyle: {
             color: '#CCC',
             fontSize:12
           },
           formatter:function (params) {
              var value=params.data;
              if (value >= 1000) {
                value = (value / 1000).toFixed(2) + 'k';
              } else if (value < 1000) {
                value = value;
              }
              return value
          }
        },
				showSymbol:true,
				color:color[0],
				data:ydata
			})
    seriesArr.push({
				name:name+'柱状',
				type:'bar',
        showBackground: true,
				barGap: 0,
        barWidth:'50%',
        itemStyle: {
            color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
            { offset: 0, color: 'rgba(184,255,248,0.8)' },
            { offset: 0.5, color: 'rgba(112,255,250,0.8)' },
            { offset: 1, color: 'rgba(34,255,249,0.8)' }
          ])
        },
        emphasis: {
          focus: 'series'
        },
				data:ydata
			})
  }
  return {
		title :{
		  text:title,
      left:'center',
      top:10,
      textStyle:{
        color:"#e6e6e6"
      }
    },
		tooltip : {
			trigger: 'axis',
			textStyle: {
				fontSize:fontsize
			}
		},
		toolbox: {show:false},
		legend:{
			top: 20,
			textStyle: {
				color: '#B7E2FF',
				fontSize:fontsize,
				fontFamily:'微软雅黑'
			},
			data:names
		},
    dataZoom: [
        {
            type: 'inside',
            xAxisIndex: 0,
        },
        {
            type: 'inside',
            zoomOnMouseWheel:true,
        }
    ],
		xAxis: {
			data: xData,
			axisLabel: {
			  rotate:30,
        showMinLabel:true,
				textStyle: {
					color: '#B7E1FF',
					fontSize:fontsize
				}
			},
			axisLine:{
				lineStyle:{
					color:'#09F'
				}
			},
			axisTick:{
				lineStyle:{
					color:'#09F'
				}
			}
		},
		yAxis: {
		  name:unit,
      nameTextStyle:{
		    color:'#e6e6e6'
      },
			splitArea: {show: false},
			axisLine:  {show: false},
			axisTick:  {show: false},
			axisLabel: {
				textStyle: {
					color: '#e6e6e6',
					fontSize:fontsize,
					fontFamily:'Arial',
				},
        formatter: function (value, index) {
          var value;
          if (value >= 1000) {
            value = (value / 1000).toFixed(2) + 'k';
          } else if (value < 1000) {
            value = value;
          }
          return value
        }
			},
			splitLine :{
				lineStyle:{
				  type:'dashed',
					color:'#09F'
				}
			}
		},
		grid: {
			left: 50
		},
		series : seriesArr
	};
};

const lineBar2 = lbObj => {
  const {title, names, messures, xValues, yValues } = lbObj
  var color=['rgba(255,153,0,0.81)','rgba(0,224,218,0.81)','rgba(61,240,152,0.8)','rgba(51,183,52,0.81)'];
  let fontsize=12;
  let yAx = []
  let sers = []
  for (let idx in messures){
    yAx.push({
      type: 'value',
      name:messures[idx],
      nameTextStyle:{
		    color:'#e6e6e6'
      },
			splitArea: {show: false},
			axisLine:  {show: false},
			axisTick:  {show: false},
			axisLabel: {
				textStyle: {
					color: '#e6e6e6',
					fontSize:fontsize,
					fontFamily:'Arial',
				},
        formatter: function (value, index) {
          var value;
          if (value >= 1000) {
            value = (value / 1000).toFixed(2) + 'k';
          } else if (value < 1000) {
            value = value;
          }
          return value
        }
			},
			splitLine :{
				lineStyle:{
				  type:'dashed',
					color:'#09F'
				}
			}
    })
    let comOpt = {
      name: names[idx],
      type: 'bar',
      showBackground: true,
      barGap: 0,
      barWidth:'50%',
      itemStyle: {
          color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
          { offset: 0, color: 'rgba(184,255,248,0.8)' },
          { offset: 0.5, color: 'rgba(112,255,250,0.8)' },
          { offset: 1, color: 'rgba(34,255,249,0.8)' }
        ])
      },
      emphasis: {
        focus: 'series'
      },
      label:{
        show: true,
         position: 'top',
         textStyle: {
           color: '#CCC',
           fontSize:12
         },
         formatter:function (params) {
            var value=params.data;
            if (value >= 1000) {
              value = (value / 1000).toFixed(2) + 'k';
            } else if (value < 1000) {
              value = value;
            }
            return value
        }
      },
      yAxisIndex:idx,
      tooltip: {
        valueFormatter: function (value) {
          return value + messures[idx];
        }
      },
      data: yValues[idx],
      showSymbol:true
    }
    if (idx>0){
      comOpt.type='line'
      comOpt.color=color[0]
      delete comOpt['barWidth']
      delete comOpt['barGap']
      delete comOpt['itemStyle']
      delete comOpt['label']
    }
    sers.push(comOpt)
  }
  return {
    title :{
		  text:title,
      left:'center',
      top:10,
      textStyle:{
        color:"#e6e6e6"
      }
    },
    tooltip: {
      trigger: 'axis',
      axisPointer: { // 坐标轴指示器，坐标轴触发有效
        type: 'shadow' // 默认为直线，可选为：'line' | 'shadow'
      }
    },
    dataZoom: [
      {
          type: 'inside',
          xAxisIndex: 0,
      },
      {
          type: 'inside',
          zoomOnMouseWheel:true,
      }
    ],
    grid: {
      top: '20%',
      left: '2%',
      right: '2%',
      bottom: '3%',
      containLabel: true
    },
    legend: {
      icon: 'rect',
      itemWidth: 14,
      itemHeight: 5,
      itemGap: 13,
      data: names,
      textStyle: {
				color: '#e6e6e6',
				fontSize:fontsize,
				fontFamily:'微软雅黑'
			},
    },
    xAxis: [{
      type: 'category',
      axisLabel: {
			  rotate:30,
        showMinLabel:true,
				textStyle: {
					color: '#B7E1FF',
					fontSize:fontsize
				}
			},
			axisLine:{
				lineStyle:{
					color:'#09F'
				}
			},
			axisTick:{
				lineStyle:{
					color:'#09F'
				}
			},
      data: xValues
    }],
    yAxis: yAx,
    series: sers
  }
};

let businessProgress_placeHoledStyle = {
		normal:{
			barBorderColor:'rgb(228,216,20)',
			color:'rgba(228,216,20,0.5)'
		},
		emphasis:{
			barBorderColor:'rgb(228,216,20)',
			color:'rgba(228,216,20,0.51)'
		}
	};
let	businessProgress_dataStyle = {
		normal: {
			barBorderColor:'rgba(0,102,255,1)',
			color:function(d){
				return 'rgba(0,102,255,0.3)';
			},
			label : {
				show: true,
				position: 'insideLeft',
				formatter: '{c}%',
				textStyle: {
					fontFamily:'Arial',
					fontWeight: 'bolder',
					color:'#B7E1FF',
					fontSize:24
				}
			}
		}
	};

let	businessProgress_option = {
		title: {show:false},
		tooltip : {
			trigger: 'axis',
			axisPointer : {
				type : 'shadow'
			},
			textStyle: {
				color:'#12ff1b',
				fontSize:24
			},
			formatter : '{b}<br/>{a0}:{c0}%<br/>{a2}:{c2}%<br/>{a4}:{c4}%<br/>{a6}:{c6}%'
		},
		legend: {
			itemGap : 60,
			top:'top',
			textStyle: {
				fontFamily:'微软雅黑',
				fontWeight: 'bolder',
				color:'#B7E1FF',
				fontSize:24
			},
			data:['项目投标', '投标进度','项目进行', '项目交付']
		},
		toolbox: {show : false},
		grid: {
			left: 150
		},
		xAxis : [
			{
				type : 'value',
				position: 'top',
				axisLine:{
					lineStyle:{
					  type:'dashed',
					  color:'#09F'
					}
				},
				splitLine :{
					lineStyle:{color:'#09F'	}
				},
				axisLabel: {show: false},
			}
		],
		yAxis : [
			{
				type : 'category',
				data : ['重大业务1', '重大业务2', '重大业务3', '重大业务4'],
				axisLabel: {
					textStyle: {
						color: '#B7E1FF',
						fontSize:24
					}
				},
				axisLine:{
					lineStyle:{
					  type:'dashed',
						color:'#09F'
					}
				},
				splitLine :{
					lineStyle:{color:'#09F'	}
				}
			}
		],
		series : [
			{
				name:'项目投标',
				type:'bar',
				stack: '进度',
				itemStyle : businessProgress_dataStyle,
				data:[100, 100, 100, 70]
			},
			{
				name:'项目投标',
				type:'bar',
				stack: '进度',
				itemStyle: businessProgress_placeHoledStyle,
				data:[0, 0, 0, 30]
			},
			{
				name:'投标进度',
				type:'bar',
				stack: '进度',
				itemStyle : businessProgress_dataStyle,
				data:[100, 100, 42, 0]
			},
			{
				name:'投标进度',
				type:'bar',
				stack: '进度',
				itemStyle: businessProgress_placeHoledStyle,
				data:[0, 0, 58, 100]
			},
			{
				name:'项目进行',
				type:'bar',
				stack: '进度',
				itemStyle : businessProgress_dataStyle,
				data:[100, 100, 0, 0]
			},
			{
				name:'项目进行',
				type:'bar',
				stack: '进度',
				itemStyle: businessProgress_placeHoledStyle,
				data:[0, 0, 100, 100]
			},
			{
				name:'项目交付',
				type:'bar',
				stack: '进度',
				itemStyle : businessProgress_dataStyle,
				data:[71, 50, 0, 0]
			},
			{
				name:'项目交付',
				type:'bar',
				stack: '进度',
				itemStyle: businessProgress_placeHoledStyle,
				data:[29, 50, 100, 100]
			}
		]
	};

let lineChart=(data)=>{
  let xdata=data.xdata;
  let ydata=data.ydata;
  let title=data.title;
  let name=data.name;
  let unit=data.unit;
  let hideArea=data.hideArea
  let serie = {
    name: name,
    type: 'line',
    itemStyle: {
      normal: {
        color: '#00E0DA',
        label: {
           show: true,
           position: 'top',
           textStyle: {
             color: '#CCC',
             fontSize:12
           },
           formatter:function (params) {
              var value=params.data;
              if (value >= 1000) {
                value = (value / 1000).toFixed(2) + 'k';
              } else if (value < 1000) {
                value = value;
              }
              return value
          }
        },
        lineStyle:{
          color:'#F90',
          width:2
        }
      },
      emphasis: {
        color: '#FF0'
      }
    },
    areaStyle: {
        color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
          {
            offset: 0,
            color: 'rgba(0,224,218,0.8)'
          },
          {
            offset: 1,
            color: 'rgba(0,224,218,0.2)'
          }
        ])
      },
    showSymbol:true,
    data: ydata
  }
  serie['areaStyle']=null
  if (!hideArea){
    serie['areaStyle']={
        color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
          {
            offset: 0,
            color: 'rgba(0,224,218,0.8)'
          },
          {
            offset: 1,
            color: 'rgba(0,224,218,0.2)'
          }
        ])
      }
  }

  return {
    title:{
      text:title,
      textAlign:'center',
      left:'center',
      top:10,
      textStyle:{
        color:"#e6e6e6"
      }
    },
		xAxis: {
      type:'category',
			data:xdata,
      boundaryGap: false,
			axisLabel: {
				textStyle: {
					color: '#B7E1FF',
					fontSize:12
				},
        rotate:30,
        showMinLabel:true,
			},
			axisLine:{
				lineStyle:{
					color:'#09F'
				}
			},
			axisTick:{
				lineStyle:{
					color:'#09F'
				}
			}
		},
		yAxis:{
      type:'value',
		  name:unit,
      nameTextStyle:{
		    color:'#e6e6e6'
      },
			splitArea: {show: false},
			axisLine:  {show: false},
			axisTick:  {show: false},
			axisLabel: {
				textStyle: {
					color: '#B7E1FF',
					fontSize:12,
					fontFamily:'Arial',
				},
        formatter: function (value, index) {
          var value;
          if (value >= 1000) {
            value = (value / 1000).toFixed(2) + 'k';
          } else if (value < 1000) {
            value = value;
          }
          return value
        }
			},
			splitLine :{
				lineStyle:{
				  type:'dashed',
					color:'#09F'
				}
			}
		},
		tooltip: {
			trigger: 'axis',
			textStyle: {
				color: '#e6e6e6',
				fontSize:12
			}
		},
		grid: {
			left: 50
		},
    dataZoom:{
      type:'inside'
    },
		legend:{
			show:true,
			top: 25,
			textStyle: {
				color: '#e6e6e6',
				fontSize:12
			},
			data:[name]
		},
		series: [serie]
	}
};

var getRandomColor = function(){
  return '#'+Math.floor(Math.random()*16777215).toString(16);
};

var getMutiLineSeries=function(ydataArr,ytitleArr){
  let SeriesArr=[];
  for (let i=0;i<ydataArr.length;i++){
    let ydata=ydataArr[i];
    let title=ytitleArr[i];
    let rdColor='#F90';
    if (i>0){
      rdColor=getRandomColor();
    }
    let seriesCell={
				name: title,
				type: 'line',
				itemStyle: {
					normal: {
						//color: rdColor,
						label: {
							 show: true,
							 position: 'top',
							 textStyle: {
								 color: '#CCC',
								 fontSize:12
							 }
						},
						lineStyle:{
							//color:rdColor,
							width:2
						}
					},
					emphasis: {
						color: '#FF0'
					}
				},
				showSymbol:false,
				data: ydata
			};
			SeriesArr.push(seriesCell);
  }
  return SeriesArr;
};

let MutiLineChart=(data)=>{
  let showTitle=true;
  if (data.hideTitle){
    showTitle=false;
  }
  let xdata=data.xdata;
  let ydataArr=data.ydataArr;
  let ytitleArr=data.ytitleArr;
  let mainTitle=data.title;
  let name=data.name;
  let SeriesArr=getMutiLineSeries(ydataArr,ytitleArr);
  return {
    title:{
      show:showTitle,
      text:mainTitle,
      textStyle:{
        color:"#e6e6e6"
      }
    },
		xAxis: {
			data:xdata,
			axisLabel: {
				textStyle: {
					color: '#B7E1FF',
					fontSize:12
				}
			},
			axisLine:{
				lineStyle:{
					color:'#09F'
				}
			},
			axisTick:{
				lineStyle:{
					color:'#09F'
				}
			}
		},
		yAxis: {
		  name:name,
      nameTextStyle:{
		    color:'#e6e6e6'
      },
			inverse: false,
			splitArea: {show: false},
			axisLine:  {show: false},
			axisTick:  {show: false},
			axisLabel: {
				textStyle: {
					color: '#B7E1FF',
					fontSize:12,
					fontFamily:'Arial',
				},
        formatter: function (value, index) {
          var value;
          if (value >= 1000) {
            value = (value / 1000).toFixed(2) + 'k';
          } else if (value < 1000) {
            value = value;
          }
          return value
        }
			},
			splitLine :{
				lineStyle:{
					color:'#09F'
				}
			}
		},
		tooltip: {
			trigger: 'axis',
			textStyle: {
				color: '#000000',
				fontSize:12
			}
		},
		grid: {
			left: 50
		},
    dataZoom:{
      type:'inside'
    },
		legend:{
			show:true,
			top: 'bottom',
			textStyle: {
				color: '#e6e6e6',
				fontSize:12
			},
			data:ytitleArr
		},
		series: SeriesArr
	}
};


let fullPie=(optData)=>{
  let title=optData.title;
  let name=optData.name;
  let data=optData.data;
  return {
    title: {
        text: title,
        left: 'left',
        textStyle:{
        color:"#e6e6e6"
      }
    },
    tooltip: {
        trigger: 'item'
    },
    legend: {
        show:true,
        orient: 'vertical',
        left: 'left',
        bottom:'20',
        textStyle: {
        color: 'rgba(230,230,230,0.8)'
      }
    },
    series: [
        {
            name: name,
            type: 'pie',
            radius: '80%',
            color:['#09F', '#F90','#F35331'],
            label:{
              show:true,
              color:'#e6e6e6'
            },
            data: data,
            emphasis: {
                itemStyle: {
                    shadowBlur: 10,
                    shadowOffsetX: 0,
                    shadowColor: 'rgba(0, 0, 0, 0.5)'
                }
            }
        }
    ]
};
};

let MutiBarOption = (bar_data) => {
  const title=bar_data.title
  const unit = bar_data.unit
  const xdata=bar_data.xData
  const bars=bar_data.yData
  const names=bar_data.names
  const hideLegend=bar_data.hideLegend
  let seriesArr=[];
  for (let idx in bars){
    let topic=names[idx];
    let ydata=bars[idx];
    let serie={
        name: topic,
        type: 'bar',
        barGap: 0,
        barWidth:'50%',
        showBackground: true,
        itemStyle: {
            color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
            { offset: 0, color: 'rgba(184,255,248,0.8)' },
            { offset: 0.5, color: 'rgba(112,255,250,0.8)' },
            { offset: 1, color: 'rgba(34,255,249,0.8)' }
          ])
        },
        label: {
           show: true,
           position: 'top',
           textStyle: {
             color: '#CCC',
             fontSize:12
           },
           formatter:function (params) {
              var value=params.data;
              if (value >= 1000) {
                value = (value / 1000).toFixed(2) + 'k';
              } else if (value < 1000) {
                value = value;
              }
              return value
          }
        },
        emphasis: {
          itemStyle: {
            color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
              { offset: 0, color: 'rgb(34,255,249)' },
              { offset: 0.7, color: 'rgb(112,255,250)' },
              { offset: 1, color: 'rgb(184,255,248)' }
            ])
          }
        },
        data: ydata
      };
    seriesArr.push(serie);
  }
  return  {
    color:['#09F','#F90','#F35331'],
    title:{
      text: title,
      left: 'left',
        textStyle:{
        color:"#e6e6e6"
      }
    },
    tooltip: {
      trigger: 'axis',
      axisPointer: {
        type: 'shadow'
      }
    },
    legend: {
			show:!hideLegend,
			top: '20',
			textStyle: {
				color: '#e6e6e6',
				fontSize:12
			},
			data:names
		},
    xAxis: [
      {
        type: 'category',
        axisLabel: {
          textStyle: {
            color: '#e6e6e6',
            fontSize:12
            }
			  },
        axisTick: {show: false},
        data: xdata
      }
    ],
    yAxis: [
      {
        name:unit,
        nameTextStyle:{
          color:'#e6e6e6'
        },
        type: 'value',
        inverse: false,
        splitArea: {show: false},
        axisLine:  {show: false},
        axisTick:  {show: false},
        axisLabel: {
          textStyle: {
            color: '#e6e6e6',
            fontSize:12,
            fontFamily:'Arial',
          }
        },
        splitLine :{
          lineStyle:{
            type:'dashed',
            color:'#09F'
          }
        }
      }
    ],
    dataZoom: [
      {
        type: 'inside'
      }
    ],
    series:seriesArr
  };
};

//地图配置
let facStatus=(stat)=>{
  let statName="正常运行";
  if (stat==='inactive'){
    statName="停运";
  }else if (stat==='build'){
    statName="在建中";
  }
  return statName;
};

let mapOption = (map_data) => {
  let mapData = map_data.data;
  let curId=map_data.cur_stat_id;
  let curStats=[];
  let symbolSize=25.0;
  let activeStats=[];
  let inactiveStats=[];
  let buildingStats=[];
  for (let mapCell of mapData){
    if (mapCell.id===curId){
      curStats.push(mapCell);
    }
    if (mapCell.status==='active'){
      activeStats.push(mapCell);
    }else if (mapCell.status==='inactive'){
      inactiveStats.push(mapCell);
    }else {
      buildingStats.push(mapCell);
    }
  }
  return {
    title: {show: true},
    tooltip: {
      trigger: 'item',
      formatter: function (params) {
        let fmData=params.data;
        let cn_stat=facStatus(fmData.status);
        return '位置:'+params.name + '<br/>' +
                '坐标:('+params.value+')'+'<br/>'+
                '地址:'+fmData.address+'<br/>'+
                '状态:'+cn_stat;
      },
      textStyle: {
        color: '#050505',
        fontSize: 18
      }
    },
    legend: {
      show: true,
      textStyle: {
        color: 'rgba(230,230,230,0.8)'
      }
    },
    geo: {
      map: 'china',
      label: {
        normal: {show: false},
        emphasis: {show: false}
      },
      roam: true,
      scaleLimit: {
        min: 0.5,
        max: 5
      },
      itemStyle: {
        normal: {
          areaColor: 'rgba(0,153,255,0.6)',
          borderColor: '#09F'
        },
        emphasis: {
          areaColor: 'rgba(0,153,255,0.6)',
          borderColor: '#09F'
        }
      }
    },
    series: [{
      name: '未运行',
      type: 'scatter',
      coordinateSystem: 'geo',
      zlevel: 1,
      rippleEffect: {
        brushType: 'stroke'
      },
      symbolSize: function (val) {
        return symbolSize;
      },
      label: {
         normal: {
            show: false,
            fontFamily: '微软雅黑',
            fontSize: 24,
            color: '#FFF',
            formatter: '{b}',
            position: 'right',
            shadowBlur: 5,
            shadowColor: '#000'
          },
        emphasis: {show: true}
      },
      itemStyle: {
        normal: {color: 'rgba(255,255,0,0.8)'},
        emphasis: {color: 'rgba(246,33,87,1)'}
      },
      data: activeStats
    },
      {
        name: '运行中',
        type: 'effectScatter',
        coordinateSystem: 'geo',
        zlevel: 2,
        hoverAnimation: true,
        showEffectOn: 'render',
        rippleEffect: {
          brushType: 'stroke'
        },
        label: {
          normal: {
            show: false,
            fontFamily: '微软雅黑',
            fontSize: 24,
            color: '#FFF',
            formatter: '{b}',
            position: 'right',
            shadowBlur: 5,
            shadowColor: '#000'
          },
          emphasis: {
            show: true
          }
        },
        symbolSize: function (val) {
          return symbolSize;
        },
        itemStyle: {
          normal: {
            color: 'rgba(255,255,255,1)'
          }
        },
        data: inactiveStats
      },
      {
        name: '在建',
        type: 'scatter',
        coordinateSystem: 'geo',
        // symbol: 'pin',
        symbolSize: function (val) {
          return symbolSize;
        },
        label: {
          normal: {
            show: false,
            fontFamily: 'Arial, Helvetica, sans-serif',
            formatter: '{b}',
            textStyle: {
              color: '#FFF',
              fontSize: 18,
            }
          },
          emphasis: {show: true}
        },
        itemStyle: {
          normal: {
            color: 'rgba(246,33,87,1)', //标志颜色
          }
        },
        zlevel: 3,
        data: buildingStats
      }
    ]
  };
};

let map3dOption=(map_data)=>{
    let mapData = map_data.data;
    let activeStats=[];
    let inactiveStats=[];
    let buildingStats=[];
    for (let mapCell of mapData){
      if (mapCell.status==='active'){
        activeStats.push(mapCell);
      }else if (mapCell.status==='inactive'){
        inactiveStats.push(mapCell);
      }else {
        buildingStats.push(mapCell);
      }
    }
     return {
       title:{
         text:'电厂分布图',
         textStyle:{
           color:'#e6e6e6'
         }
       },
       tooltip: {
         trigger: 'item',
         backgroundColor:'#fff',
         formatter: function (params) {
           let fmData = params.data;
           let cn_stat = facStatus(fmData.status);
           return '位置:' + params.name + '<br/>' +
             '坐标:(' + params.value + ')' + '<br/>' +
             '地址:' + fmData.address + '<br/>' +
             '状态:' + cn_stat;
         },
         textStyle: {
           color: '#050505',
           fontSize: 18
         }
       },
       legend: {
         show: true,
         textStyle: {
           color: 'rgba(230,230,230,0.8)'
         }
       },
       visualMap: [{
         type: 'continuous',
         show: false,
         seriesIndex: 0,
         text: ['bar3D'],
         calculable: true,
         max: 300,
         inRange: {
           //color: ['#87aa66', '#eba438', '#d94d4c']
           color: ['#87aa66']
         }
       },
       {
         type: 'continuous',
         show: false,
         seriesIndex: 1,
         text: ['bar3D'],
         calculable: true,
         max: 300,
         inRange: {
           color: ['#eba438']
         }
       },
       {
         type: 'continuous',
         show: false,
         seriesIndex: 2,
         text: ['bar3D'],
         calculable: true,
         max: 300,
         inRange: {
           color: ['#d94d4c']
         }
       }],
       geo3D: {
         map: 'china',
         roam: true,
         itemStyle: {
           areaColor: 'rgb(5,101,123)',
           opacity: 1,
           borderWidth: 0.8,
           borderColor: 'rgb(22,169,215)'
         },
         label: {
           show: false,
         },
         emphasis: { //当鼠标放上去  地区区域是否显示名称
           label: {
             show: true,
             textStyle: {
               color: '#fff',
               fontSize: 3,
               backgroundColor: 'rgba(0,23,11,0)'
             }
           }
         },
         light: {
           main: {
             color: '#fff', //光照颜色
             intensity: 1.2, //光照强度
             shadowQuality: 'high', //阴影亮度
             shadow: false, //是否显示阴影
             //                        alpha: 55,
             beta: 10

           },
           ambient: {
             intensity: 0.3
           }
         }
       },
       series: [{
         name: 'bar3D',
         type: "bar3D",
         coordinateSystem: 'geo3D',
         barSize: 0.3, //柱子粗细
         shading: 'lambert',
         opacity: 0.1,
         //                bevelSize: 0.3,
         label: {
           show: false,
           formatter: function (data) {
             var res = data.name + " " + data.value[2]
             return res
           }
         },
         data: activeStats,
       },
       {
         name: 'bar3D',
         type: "bar3D",
         coordinateSystem: 'geo3D',
         barSize: 0.3, //柱子粗细
         shading: 'lambert',
         opacity: 0.1,
         label: {
           show: false,
           formatter: function (data) {
             var res = data.name + " " + data.value[2]
             return res
           }
         },
         data: inactiveStats,
       },
       {
         name: 'bar3D',
         type: "bar3D",
         coordinateSystem: 'geo3D',
         barSize: 0.3, //柱子粗细
         shading: 'lambert',
         opacity: 0.1,
         label: {
           show: false,
           formatter: function (data) {
             var res = data.name + " " + data.value[2]
             return res
           }
         },
         data: buildingStats,
       }]
     }
};



let guageOptions = (data) => {
  let unit=data.unit;
  let pieNames=data.names;
  let pieValues=data.values;
  return {
    series: [{
      type: 'gauge',
      startAngle: 180,
      endAngle: 0,
      min: 0,
      max: pieValues[0],
      splitNumber: 2,
      itemStyle: {
        color: 'rgba(0,153,255,0.81)',
        shadowColor: 'rgba(0,153,255,0.81)',
        shadowBlur: 10,
        shadowOffsetX: 2,
        shadowOffsetY: 2
      },
      progress: {
        show: true,
        roundCap: true,
        width: 15
      },
      pointer: {
        icon: 'path://M2090.36389,615.30999 L2090.36389,615.30999 C2091.48372,615.30999 2092.40383,616.194028 2092.44859,617.312956 L2096.90698,728.755929 C2097.05155,732.369577 2094.2393,735.416212 2090.62566,735.56078 C2090.53845,735.564269 2090.45117,735.566014 2090.36389,735.566014 L2090.36389,735.566014 C2086.74736,735.566014 2083.81557,732.63423 2083.81557,729.017692 C2083.81557,728.930412 2083.81732,728.84314 2083.82081,728.755929 L2088.2792,617.312956 C2088.32396,616.194028 2089.24407,615.30999 2090.36389,615.30999 Z',
        length: '75%',
        width: 13,
        offsetCenter: [0, '5%']
      },
      axisLine: {
        roundCap: true,
        lineStyle: {
          width: 15
        }
      },
      axisTick: {
        splitNumber: 2,
        lineStyle: {
          width: 2,
          color: '#e6e6e6'
        }
      },
      splitLine: {
        length: 12,
        lineStyle: {
          width: 3,
          color: '#e6e6e6'
        }
      },
      axisLabel: {
        show:true,
        //distance: 30,
        color: '#e6e6e6',
        fontSize: 15
      },
      detail: {
        width: '60%',
        lineHeight: 80,
        height: 40,
        offsetCenter: [0, '35%'],
        valueAnimation: true,
        formatter: function (value) {
          let guaname=pieNames[1]+":"+ value.toFixed(0);
          return '{value|'+guaname + '}'+'{unit|'+unit+'}';
        },
        rich: {
          value: {
            fontSize: 20,
            fontWeight: 'bolder',
            color: '#e6e6e6'
          },
          unit: {
            fontSize: 15,
            color: '#e6e6e6',
            padding: [0, 0, 0, 10]
          }
        }
      },
      data: [{
        value: pieValues[1]
      }]
    }]
  }
};


let chartTool={
  getMutiLineSeries
};

export default {
  chartTool, //各类图表计算函数
  pieProcess, //环形进度图
  lineBar, //线条柱状图
  lineBar2, //线条柱含双Y轴
  stackBar:businessProgress_option, //柱状堆叠图
  lineChart, //线条图
  MutiLineChart, //线条组图
  MutiBarOption, //柱状组图
  mapOption, //2D地图
  map3dOption, //3D地图
  fullPie, //饼图
  guageOptions //进度盘
}
